﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.IO;
using ScrumTable.Common;
using ScrumTable.DL.Data.Schema.ScrumTableV1;
using ScrumTable.DL.Data.Schema.Serialization;

#endregion

namespace ScrumTable.DL.Data.Schema
{
    /// <summary>
    /// Contains additional information about the ScrumTable protocol
    /// schema. This instance follows the singleton pattern.
    /// </summary>
    public class SchemaFactory : SchemaBase
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        private const string SchemaClassName = "ScrumTable.DL.Data.Schema.{0}.{0}Schema";

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates and fills a new schema instance.
        /// </summary>
        /// <param name="dataToInitialize">Specifies the schema data which will be used to initialize the schema instance.</param>
        public static ScrumTableV1Schema CreateSchema(SchemataRoot dataToInitialize)
        {
            PreCondition.AssertNotNull(dataToInitialize, "dataToInitialize");

            string schmataClassName = string.Format(SchemaClassName, dataToInitialize.Version);
            Type schemataType = Type.GetType(schmataClassName, true, false);
            return (ScrumTableV1Schema)Activator.CreateInstance(schemataType, new object[] { dataToInitialize });
        }

        #endregion
    }
}